Skip to main content

GetBookmark

Returns a bookmark by its name from the current document.

Syntax

expression.GetBookmark(sBookmarkName);

expression - A variable that represents a ApiDocument class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sBookmarkNameRequiredstringThe bookmark name.

Returns

ApiBookmark

Example

This example shows how to get bookmark in document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
let range1 = doc.GetRange(0, 11);
range1.AddBookmark("Bookmark_ex");
let bookmark = doc.GetBookmark("Bookmark_ex");
paragraph.AddLineBreak();
paragraph.AddText("Bookmark with name '" + bookmark.GetName() + "' surrounds text: " + bookmark.GetText());